<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加站点类型</title>
    <link rel="stylesheet" href="/js/layui/css/layui.css" media="all">
    <script src="/js/layui/layui.all.js"></script>
    <script src="/admin/js/token.js"></script>
</head>
<style>
</style>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body" pad15>
                    <form class="layui-form" lay-filter="selFilter">
                        <div class="layui-form-item">
                            <lable class="layui-form-label">站点名称</lable>
                            <div class="layui-input-block">
                                <input type="text" lay-verify="required" placeholder="如酒店，足浴" autocomplete="off"
                                       class="layui-input"
                                       style="width: 50%" id="typename">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">类型状态</label>
                            <div class="layui-input-block" style="width: 30%">
                                <select name="type" lay-verify="required" id="status">
                                    <option value="">请选择状态</option>
                                    <option value="禁用">禁用</option>
                                    <option value="启用">启用</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn layui-btn-sm layui-icon layui-icon-survey" lay-submit=""
                                        id="update" lay-filter="update">
                                    修改
                                </button>
                                <button class="layui-btn layui-btn-sm layui-icon layui-icon-close" id="back">
                                    取消
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
        var form = layui.form
        var $ = layui.$
        form.render('select', 'selFilter');
        form.on('submit(add)', function (data) {
            $.ajax({
                type: 'post',
                url: '/admin/station-type/addstationtype',
                data: {stationTypeName: $('#typename').val(), stationTypeStatus: $('#status').val()},
                success: function (res) {
                    if (res.code == 200) {
                        layer.msg('新增成功', {
                            icon: 1
                        });
                        setTimeout(function () {
                            //先得到当前iframe层的索引
                            var index = parent.layer.getFrameIndex(window.name);
                            //再执行关闭
                            parent.layer.close(index);
                            //关闭父级页面的表格
                            parent.layui.table.reload('t');
                        }, 1500)
                    } else if (res.code == 400) {
                        layer.msg(res.data, {
                            icon: 2
                        })
                    } else {
                        layer.msg('新增失败', {
                            icon: 2
                        })
                    }
                },
                error: function (res) {
                    layer.msg('系统原因新增失败', {
                        icon: 2
                    })
                }
            })
            return false
        })
        $('#back').click(function () {
            var index = parent.layer.getFrameIndex(window.name) //获取窗口索引
            parent.layer.close(index)    //关闭弹出层
        })
</script>
</body>
</html>
